/**
  ******************************************************************************
  * File Name          : storage.c
  * Description        : Code for storage applications
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include <string.h>
#include "tskcfg.h"
#include "bsp.h"
#include "storage.h"

TaskHandle_t xStoragePara_Thd = NULL;
StaticTask_t xStoragePara_Tcb;
StackType_t  xStoragePara_Stk[ STGPARA_STACK_SIZE ];

QueueHandle_t        Storage_qhd = NULL;
static StaticQueue_t storage_stru;
static uint8_t       storage_area[STORAGE_QUE_LENGTH  * STORAGE_QUE_ITEMSIZE];

void Storage_Parameter(void)
{
	eEProm_Init();
	
	if(Storage_xx_load() != 0)
	{
		printf("System parameter load error!\r\n");
	}
  else
  {
    printf("System parameter load success...\r\n");
  }
}

void vStoragePara_Task( void * pvParameters )
{
	uint8_t sftype;

	Storage_qhd = xQueueCreateStatic(STORAGE_QUE_LENGTH, STORAGE_QUE_ITEMSIZE,
	                                 storage_area, &storage_stru);
  
  Storage_Parameter();
  
	while(1)
	{
		if(xQueueReceive(Storage_qhd, &sftype, portMAX_DELAY) == pdTRUE)
		{
			Storage_xx_save(sftype);
		}
	}
}
